package kr.or.kosta.otr.service.reviewservice;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.annotation.Resource;

import kr.or.kosta.otr.persistence.company.CompanyDao;
import kr.or.kosta.otr.persistence.companyreview.CompanyReviewDao;
import kr.or.kosta.otr.persistence.companyreviewverify.CompanyReviewVerifyDao;
import kr.or.kosta.otr.persistence.industry.IndustryDao;
import kr.or.kosta.otr.persistence.interestcompany.InterestCompanyDao;
import kr.or.kosta.otr.persistence.mentor.MentorDao;
import kr.or.kosta.otr.persistence.message.MessageDao;
import kr.or.kosta.otr.persistence.messagetype.MessageTypeDao;
import kr.or.kosta.otr.persistence.profession.ProfessionDao;
import kr.or.kosta.otr.persistence.region.RegionDao;
import kr.or.kosta.otr.persistence.score.ScoreDao;
import kr.or.kosta.otr.persistence.trueorfalse.TrueOrFalseDao;
import kr.or.kosta.otr.persistence.user.UserDao;
import kr.or.kosta.otr.vo.CompanyReviewVO;
import kr.or.kosta.otr.vo.CompanyReviewVerifyVO;
import kr.or.kosta.otr.vo.CompanyVO;
import kr.or.kosta.otr.vo.IndustryVO;
import kr.or.kosta.otr.vo.InterestCompanyVO;
import kr.or.kosta.otr.vo.MentorVO;
import kr.or.kosta.otr.vo.MessageTypeVO;
import kr.or.kosta.otr.vo.MessageVO;
import kr.or.kosta.otr.vo.ProfessionVO;
import kr.or.kosta.otr.vo.RegionVO;
import kr.or.kosta.otr.vo.ScoreVO;
import kr.or.kosta.otr.vo.TrueOrFalseVO;

import org.springframework.stereotype.Service;
@Service("ReviewService")
public class ReviewServiceImpl implements ReviewService{
	
	@Resource(name="CompanyDao")
	CompanyDao companyDao;
	
	@Resource(name="RegionDao")
	RegionDao regionDao;
	
	@Resource(name="IndustryDao")
	IndustryDao industryDao;
	
	@Resource(name="ProfessionDao")
	ProfessionDao professionDao;
	
	@Resource(name="CompanyReviewDao")
	CompanyReviewDao companyReviewDao;
	
	@Resource(name="CompanyReviewVerifyDao")
	CompanyReviewVerifyDao companyReviewVerifyDao;

	@Resource(name="ScoreDao")
	ScoreDao scoreDao;
	
	@Resource(name="TrueOrFalseDao")
	TrueOrFalseDao trueOrFalseDao;
	
	@Resource(name="UserDao")
	UserDao userDao;
	
	@Resource(name="InterestCompanyDao")
	InterestCompanyDao interestCompanyDao;
	
	@Resource(name="MessageTypeDao")
	MessageTypeDao messageTypeDao;
	
	@Resource(name="MessageDao")
	MessageDao messageDao;
	
	@Resource(name="MentorDao")
	MentorDao mentorDao;
	
	@Override
	public ArrayList<CompanyVO> getAllCompany() throws SQLException {
		 
		return companyDao.getAllCompany();
	}

	@Override
	public ArrayList<IndustryVO> getAllIndustry() throws SQLException {
		
		return industryDao.getAllIndustry();
	}

	@Override
	public ArrayList<ProfessionVO> getAllProfession() throws SQLException {
		
		return professionDao.getAllProfession();
	}

	@Override
	public ArrayList<RegionVO> getAllRegion() throws SQLException {
		
		return regionDao.getAllRegion();
	}

	@Override
	public void writeCompanyReview(CompanyReviewVO vo) throws SQLException {
		companyReviewDao.writeCompanyReview(vo);
		
	}

	@Override
	public ArrayList<CompanyVO> getCompanyInfo(HashMap<String, Object> map)
			throws SQLException {
		
		return companyDao.getCompanyInfo(map);
	}

	@Override
	public IndustryVO getIndustry(HashMap<String, Object> map)
			throws SQLException {
		
		return industryDao.getIndustry(map);
	}

	@Override
	public ProfessionVO getProfession(HashMap<String, Object> map)
			throws SQLException {
		
		return professionDao.getProfession(map);
	}

	@Override
	public int writeCompanyReviewVerify(CompanyReviewVerifyVO vo)
			throws SQLException {
		return companyReviewVerifyDao.writeCompanyReviewVerify(vo);
		
	}

	@Override
	public void writeScore(ScoreVO scoreVo) throws SQLException {
		
		scoreDao.writeScore(scoreVo);
	}

	@Override
	public ArrayList<CompanyReviewVO> getCompanyReviewByCompanyName(
			String companyName) throws SQLException {
		
		return companyReviewDao.getCompanyReviewByCompanyName(companyName);
	}

	@Override
	public void updateTotalScore(int scoreId) throws SQLException {
		scoreDao.updateTotalScore(scoreId);
		
	}

	@Override
	public RegionVO getRegion(HashMap<String, Object> map) throws SQLException {
		
		return regionDao.getRegion(map);
	}

	@Override
	public float getCompanyScoreTotal(int companyId) throws SQLException {
		
		return scoreDao.getCompanyScoreTotal(companyId);
	}

	@Override
	public float getTotalScoreOfChance(int companyId) throws SQLException {
		
		return scoreDao.getTotalScoreOfChance(companyId);
	}

	@Override
	public float getTotalScoreOfWelfare(int companyId) throws SQLException {
		return scoreDao.getTotalScoreOfWelfare(companyId);
	}

	@Override
	public float getTotalScoreOfCulture(int companyId) throws SQLException {
		return scoreDao.getTotalScoreOfCulture(companyId);
	}

	@Override
	public float getTotalScoreOfHoliday(int companyId) throws SQLException {
		return scoreDao.getTotalScoreOfHoliday(companyId);
	}

	@Override
	public float getTotalScoreOfExecutive(int companyId) throws SQLException {
		return scoreDao.getTotalScoreOfExecutive(companyId);
	}

	@Override
	public float getTotalScoreOfOverdue(int companyId) throws SQLException {
		return scoreDao.getTotalScoreOfOverdue(companyId);
	}

	@Override
	public ArrayList<CompanyReviewVerifyVO> getOneCompanyReviewVerify(
			int companyReviewId) throws SQLException {
		
		return companyReviewVerifyDao.getOneCompanyReviewVerify(companyReviewId);
	}

	@Override
	public ArrayList<TrueOrFalseVO> getCompanyReviewVerifyByCompanyId(
			int companyId) throws SQLException {
		ArrayList<TrueOrFalseVO> crv =  companyReviewVerifyDao.getCompanyReviewVerifyByCompanyId(companyId);
		
		return crv;
	}

	@Override
	public CompanyVO getOneCompany(int companyId) throws SQLException {
		// TODO Auto-generated method stub
		return companyDao.getOneCompany(companyId);
	}

	@Override
	public int isExistCompanyReviewVerifyByCompanyId(int companyId)
			throws SQLException {
		// TODO Auto-generated method stub
		return companyReviewVerifyDao.isExistCompanyReviewVerifyByCompanyId(companyId);
	}

	@Override
	public void insertTruthOrFalse(int companyRevicewVerifyId)
			throws SQLException {
		// TODO Auto-generated method stub
		trueOrFalseDao.insertTruthOrFalse(companyRevicewVerifyId);
	}

	@Override
	public void increaseTruth(HashMap<String, Object> map) throws SQLException {
		// TODO Auto-generated method stub
		trueOrFalseDao.increaseTruth(map);
	}

	@Override
	public void increaseObjection(HashMap<String, Object> map)
			throws SQLException {
		// TODO Auto-generated method stub
		trueOrFalseDao.increaseObjection(map);
	}

	@Override
	public String getOneTruthByReviewVerifyId(int companyRevicewVerifyId)
			throws SQLException {
		// TODO Auto-generated method stub
		return trueOrFalseDao.getOneTruthByReviewVerifyId(companyRevicewVerifyId);
	}

	@Override
	public String getOneObjectionByReviewVerifyId(int companyRevicewVerifyId)
			throws SQLException {
		// TODO Auto-generated method stub
		return trueOrFalseDao.getOneObjectionByReviewVerifyId(companyRevicewVerifyId);
	}

	@Override
	public void updatePointPlus(HashMap<String, Object> map)
			throws SQLException {
		userDao.updatePointPlus(map);
		
	}

	@Override
	public int getUserPoint(String userId) throws SQLException {
		// TODO Auto-generated method stub
		return userDao.getUserPoint(userId);
	}

	@Override
	public void setCompanyTotalScore(HashMap<String, Object> map)
			throws SQLException {
		companyDao.setCompanyTotalScore(map);
		
	}

	@Override
	public ArrayList<InterestCompanyVO> getAllInterestCompanyList(int companyId)
			throws SQLException {
		
		return interestCompanyDao.getAllInterestCompanyList(companyId);
	}

	@Override
	public MessageTypeVO getMessageType(HashMap<String, Object> map)
			throws SQLException {
		
		return messageTypeDao.getMessageType(map);
	}

	@Override
	public void writeMessage(MessageVO vo) throws SQLException {
		messageDao.writeMessage(vo);
		
	}

	@Override
	public ArrayList<MentorVO> getAllMentor(HashMap<String, Object> map)
			throws SQLException {
		// TODO Auto-generated method stub
		return mentorDao.getAllMentor(map);
	}

	@Override
	public ArrayList<TrueOrFalseVO> getCompanyReviewVerifyByCompanyIdPage(
			HashMap<String, Object> map) throws SQLException {
		int pn=1;
		String pageNo = (String) map.get("value");
		if(pageNo!=null){
			pn=Integer.parseInt(pageNo);
		}
		map.put("value", pn);
		ArrayList<TrueOrFalseVO> list= companyReviewVerifyDao.getCompanyReviewVerifyByCompanyIdPage(map);
		
		return list;
	}

	@Override
	public int getCompanyReviewVerifyByCompanyIdTotal(int companyId)
			throws SQLException {
		
		return companyReviewVerifyDao.getCompanyReviewVerifyByCompanyIdTotal(companyId);
	}
	
}
